package com.bootx.redis.listener;

import io.lettuce.core.cluster.models.partitions.RedisClusterNode;
import io.lettuce.core.cluster.pubsub.RedisClusterPubSubAdapter;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author Tony.niu (hystrix0779@yeah.net)
 * @version V1.0
 * @date 2020/8/20
 **/
@Component
@Slf4j
public class ListenerGrooveAdapter extends RedisClusterPubSubAdapter {

    private static final Logger logger = LoggerFactory.getLogger(ListenerGrooveAdapter.class);

    @Override
    public void message(RedisClusterNode node, Object channel, Object message) {
        String expiredKey = null;
        try {
            expiredKey = (String) message;
            log.info("redisCluster{}的Key:{}过期",node.getUri(),expiredKey);

        } catch (Exception e) {
            logger.error("错误的过期消息类型");
        }
    }

}
